import 'package:flutter/material.dart';
// import 'package:flutter_statusbarcolor_ns/flutter_statusbarcolor_ns.dart';

enum StatusStyle { LIGHT_CONTENT, DARK_CONTENT }

class NavigationTopBar extends StatelessWidget {
  final StatusStyle statusStyle;
  final Color color;
  final double height;
  final Widget child;

  const NavigationTopBar(
    this.child, {
    super.key,
    this.statusStyle = StatusStyle.DARK_CONTENT,
    this.color = Colors.white,
    this.height = 46,
  });

  @override
  Widget build(BuildContext context) {
    //设置状态栏颜色
    _statusBarInit();
    //获取状态栏高度，比如苹果刘海屏，灵动岛
    var top = MediaQuery.of(context).padding.top;
    var width = MediaQuery.of(context).size.width;
    print("top:$top");
    print("width:$width");
    return Container(
      //获取屏幕的宽度
      width: MediaQuery.of(context).size.width,
      height: top + height,
      padding: EdgeInsets.only(top: top),
      decoration: BoxDecoration(color: color),
      child: child,
    );
  }

  void _statusBarInit() async {
    //沉浸式状态栏样式
    // await FlutterStatusbarcolor.setStatusBarColor(color);
    // if(StatusStyle.DARK_CONTENT == statusStyle){
    //   await FlutterStatusbarcolor.setStatusBarWhiteForeground(false);
    // }else{
    //   await FlutterStatusbarcolor.setStatusBarWhiteForeground(true);
    // }
  }
}
